package com.xzlzx.geb

import geb.Browser
import org.openqa.selenium.firefox.FirefoxBinary
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions

class GebDemo {

    static void main(def args) {

        def path = "D:\\work\\geb-study\\src\\main\\resources\\geckodriver.exe"
        System.setProperty("webdriver.gecko.driver", path)
        File pathToFirefoxBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe")
        FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary)
        firefoxbin.addCommandLineOptions("--headless")
        FirefoxOptions firefoxOptions = new FirefoxOptions()
        firefoxOptions.setBinary(firefoxbin)


        def browser = new Browser(driver: new FirefoxDriver(firefoxOptions))

        browser.with {

            go "https://m.jd.com"

            $(".close.j_close_curtain").click()
            $("#msShortcutLogin").click()

            $("#username").value(username)
            $("#password").value(password)

            $("#loginBtn").click()

            sleep(5000)

        }
    }
}
